#ifndef FFMPEG_PLAYER_H
#define FFMPEG_PLAYER_H
#include "drmDisplay.h"
#include <errno.h>
#include <fcntl.h>
#include <iostream>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <time.h>
#include <unistd.h>

extern "C" {
#include "libavutil/imgutils.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavutil/avassert.h>
#include <libavutil/hwcontext.h>
#include <libavutil/hwcontext_drm.h>
#include <libavutil/opt.h>
#include <libavutil/pixdesc.h>
#include <libswscale/swscale.h>
}

class C_FfmpegPlayer
{
public:
	C_FfmpegPlayer();
	~C_FfmpegPlayer();
	void SetFilePath(const char *filePath);
	void SetHwdevice(const char *hwdevice);
	int InitFfmpeg();
	int InitHWDecoder(AVCodecContext *ctx, const enum AVHWDeviceType type);
	int Play(C_DRMDisplay cDRMDisplay);

private:
	const char *pMediaPath;
	const char *pHWDevice;
	AVFormatContext *pFmtCtx;
	AVStream *pStream;
	AVCodecContext *pCodecCtx;
	const AVCodec *pCodec;
	AVPacket *pPacket;
	AVBufferRef *pHWDeviceCtx;
	enum AVPixelFormat stHWPixFmt;
	int iFrameRate;
	int iVideoStream;
};

#endif